package room;

import java.util.HashMap;

import interfaces.IDescribable;
import items.Item;
import commands.Commandable;
import commands.Commands;

public class RoomState extends Commandable implements IDescribable
{
  private static int nextID = 0;
  private int id;
  private String description = "";
  private HashMap<Item, Commands> reactions;
  
  public RoomState()
  {
    this("");
  }

  public RoomState(String description)
  {
    this.id = nextID++;
    this.description = description;
    reactions = new HashMap<Item, Commands>();
  }
   
  public Commands addItemReaction(Item item)
  {
    Commands c = new Commands();
    reactions.put(item, c);
    return c;
  }
  
  public String useItem(Item item)
  {
    Commands c = reactions.get(item);
    return (c == null ? "" : c.runCommands());
  }
  
  public String toString()
  {
    return super.toString();
  }
  
  /**
   * @return the id
   */
  public int getId()
  {
    return id;
  }
  
  /**
   * Used for the Saving and Loading
   * @param id the id to set
   */
  public void setId(int id)
  {
    this.id = id;
  }
  
  /**
   * @return the description
   */
  public String getDescription()
  {
    return description;
  }

  /**
   * @param description the description to set
   */
  public void setDescription(String description)
  {
    this.description = description;
  }
}
